//@Grab('com.xlson.groovycsv:groovycsv:1.0')

import static com.xlson.groovycsv.CsvParser.*
import groovy.json.JsonBuilder
import com.xlson.groovycsv.CsvParser

def threatsList = []

//ServletContext context = getContext();
URL url = context.getResource("/geoTweets.csv");

def csvdata =  new CsvParser().parse(url.text, autoDetect:true)

class ThreatDef{
	String id
	String categories
	String lat
	String lng
	String drugreference
	String businessofinterest
	String humantrafficking
}

for (line in csvdata){
	threatsList << new ThreatDef (id:  line.id, categories: line.categories,
	drugreference: line.drugreference, businessofinterest: line.businessofinterest, humantrafficking: line.humantrafficking,
	lat: line.lat, lng: line.lng )
}

def json = new JsonBuilder(threatsList)
//System.out.println (json);
//println json.toPrettyString()
out.println(json)